package com.hlf.eduservice.controller;


import com.atguigu.commonutils.R;
import com.hlf.eduservice.entity.subject.OneSubject;
import com.hlf.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author hlf
 * @since 2022-11-27
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    // 添加课程分类
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file) {
    //1 获取上传的excel文件 MultipartFile
    //返回错误提示信息
        subjectService.saveSubject(file,subjectService);
     //判断返回集合是否为空
        return R.ok();
    }

    @GetMapping("getAllSubject")
     public R getAllSubject(){
       List<OneSubject> list = subjectService.getAllOneTwoSubject();
       return R.ok().data("list",list);
    }

}



